/*******************************************************************************
 * Copyright (c) 2008 Smart Mai(smardio@gmail.com).
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the 
 * GNU Lesser General Public License, version 2.1
 * which accompanies this distribution, and is available at
 * http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html
 * 
 * Contributors:
 *     Smart Mai(smardio@gmail.com) - initial API and implementation
 ******************************************************************************/
package com.smartdio.example.util;

import java.util.Vector;

/**
 * 演示Java 5泛型的简单应用
 * @author smart
 *
 */
public class GenericTypeDemo {
	

	/**
	 * Java 5之前的语法
	 */
	public void oldStyle(){
		Vector list = new Vector();
		for(int i=0;i<10;i++){
			String str= "row:"+i;
			list.add(str);
		}
		
		for(int i=0;i<list.size();i++){
			String str=(String)list.get(i);
			System.out.println(str);
		}
	}
	
	/**
	 * Java 5 之后的语法
	 */
	public void newStyle(){
		Vector<String> list = new Vector<String>();
		for(int i=0;i<10;i++){
			String str= "row:"+i;
			list.add(str);
		}
		for(String str:list){
			System.out.println(str);
		}
	}

}
